﻿<UserControls:ScrumUserControl x:Class="ScrumTable.UI.View.WinTouch.UserControls.View.MemberSetting"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008" xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View"
    xmlns:Localization="clr-namespace:ScrumTable.UI.View.Localization;assembly=ScrumTable.UI.View"  xmlns:ViewModel="clr-namespace:ScrumTable.UI.ViewModel;assembly=ScrumTable.UI.ViewModel" xmlns:UserControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:CustomControl="clr-namespace:ScrumTable.UI.View.WinTouch.CustomControl"
                               xmlns:customControl="clr-namespace:ScrumTable.UI.View.CustomControl;assembly=ScrumTable.UI.View"
                               Background="{StaticResource ScreenConfiguration}"
                               x:Name="BaseScroller"
                               >
    <CustomControl:ScrumTableScrollViewer  HorizontalScrollBarVisibility="Visible"  Margin="75,20,75,0" HorizontalAlignment="Stretch" VerticalAlignment="Top" >
        <Grid HorizontalAlignment="Stretch">    
            <Grid.Resources>
                <Converter:ConverterIsNull x:Key="ConverterIsNull" IsEmpty="True"/>
                <Converter:CalcConverter CalcType="Multi" ValueRight="0.45" x:Key="Div2CalcConverter"></Converter:CalcConverter>
                <Converter:CalcConverter CalcType="Sub" ValueRight="50" x:Key="MinCalcConverter"></Converter:CalcConverter>
            </Grid.Resources>
            <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top" >
                <Grid.Resources>

                    <Style TargetType="{x:Type Label}">
                        <Setter  Property="VerticalAlignment"  Value="Center"/>
                        <Setter  Property="FontSize"  Value="15"/>
                        <Setter Property="FontWeight" Value="Bold"/>
                    </Style>
                    <DataTemplate x:Key="listTemplate">
                        <DockPanel>
                            <UserControls:MemberControl DataContext="{Binding}"/>
                        </DockPanel>
                    </DataTemplate>
                    <DataTemplate x:Key="listTemplateTeam">
                        <UserControls:MemberControl DataContext="{Binding Member}"/>
                     </DataTemplate>
                </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="410" />
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type CustomControl:ScrumTableScrollViewer}}, Converter={StaticResource Div2CalcConverter}}" />
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type CustomControl:ScrumTableScrollViewer}}, Converter={StaticResource Div2CalcConverter}}" />
                </Grid.ColumnDefinitions>
 
                <Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource DescriptionLabel}">
                    <Label.Content>
                        <Localization:Translate Uid="TeamSettings_ShowMembers" Default="[Displayed Members]" />
                    </Label.Content>
                </Label>

                <Label Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource DescriptionLabel}">
                    <Label.Content>
                        <Localization:Translate Uid="TeamSettings_HiddenMembers" Default="[Hidden Members]" />
                    </Label.Content>
                </Label>

                <UserControls:SurfaceDragDropListBox Margin="0,0,0,0"
                    x:Name="ListShow"
                    MultipleColumnsRows="True"
                    Opacity="0.75"            
                    AllowDrop="True"             
                    AddOnDrop="False"
                    ItemsSource="{Binding Path=TeamMembers, Mode=OneWay}"            
                    Orientation="Vertical"
                    s:SurfaceDragDrop.Drop="OnShowDrop"
                    AllowedDropType="{x:Type ViewModel:MemberViewModel}"
                    Grid.Column="0" Grid.Row="1" ItemTemplate="{StaticResource listTemplateTeam}">
                     
                    <UserControls:SurfaceDragDropListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControls:SurfaceDragDropListBox}}, Converter={StaticResource MinCalcConverter}}"/>
                        </ItemsPanelTemplate>
                    </UserControls:SurfaceDragDropListBox.ItemsPanel>
                    
                    <UserControls:SurfaceDragDropListBox.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.ContainerStyle>
                                <Style TargetType="{x:Type GroupItem}">
                                    <Setter Property="Margin" Value="0,0,0,30"/>
                                 </Style>
                            </GroupStyle.ContainerStyle>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate>
                                    <TextBlock FontWeight="Bold" FontSize="14" Text="{Binding Name}" Foreground="Black" />
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                        </GroupStyle>
                    </UserControls:SurfaceDragDropListBox.GroupStyle>

                    <UserControls:SurfaceDragDropListBox.ChildTypeAsDragDropSource>
                        <x:Array Type="{x:Type sys:Type}">
                            <x:Type  TypeName="UserControls:MemberControl"></x:Type>
                        </x:Array>
                    </UserControls:SurfaceDragDropListBox.ChildTypeAsDragDropSource>
                </UserControls:SurfaceDragDropListBox>



                <UserControls:SurfaceDragDropListBox Margin="0,0,0,0"
                    x:Name="ListHidden"
                    MultipleColumnsRows="True"
                    Opacity="0.75"
                    AllowDrop="True"
                    AddOnDrop="False"
                    ItemsSource="{Binding Path=MembersFiltered}"
                    Orientation="Vertical"
                    s:SurfaceDragDrop.Drop="OnHiddenDrop"
                    AllowedDropType="{x:Type ViewModel:MemberViewModel}"
                    Grid.Column="2" Grid.Row="1" ItemTemplate="{StaticResource listTemplateTeam}">
                    <UserControls:SurfaceDragDropListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControls:SurfaceDragDropListBox}}, Converter={StaticResource MinCalcConverter}}"/>
                        </ItemsPanelTemplate>
                    </UserControls:SurfaceDragDropListBox.ItemsPanel>


                    <UserControls:SurfaceDragDropListBox.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.ContainerStyle>
                                <Style TargetType="{x:Type GroupItem}">
                                    <Setter Property="Margin" Value="0,0,0,30"/>
                                </Style>
                            </GroupStyle.ContainerStyle>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate>
                                    <TextBlock FontWeight="Bold" FontSize="14" Text="{Binding Name}" Visibility="{Binding Name, Converter={StaticResource ConverterIsNull}}" Foreground="Black"/>
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                        </GroupStyle>
                    </UserControls:SurfaceDragDropListBox.GroupStyle>

                    <UserControls:SurfaceDragDropListBox.ChildTypeAsDragDropSource>
                        <x:Array Type="{x:Type sys:Type}">
                            <x:Type  TypeName="UserControls:MemberControl"></x:Type>
                        </x:Array>
                    </UserControls:SurfaceDragDropListBox.ChildTypeAsDragDropSource>
                </UserControls:SurfaceDragDropListBox>


                <s:SurfaceButton Grid.Row="1" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Center" Height="205" Width="70" Background="{StaticResource MoveRight}" Click="HideMembersClick"/>
                <s:SurfaceButton Grid.Row="1" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Center" Height="205" Width="70" Background="{StaticResource MoveLeft}" Click="ShowMembersClick"/>


                <Image  HorizontalAlignment="Stretch" Grid.Row="2" Height="100"  Grid.Column="0" VerticalAlignment="Top" Margin="0,0,0,0" s:SurfaceDragDrop.Drop="OnColorWheelDrop" AllowDrop="True"  Stretch="Fill" Name="ColorWheel" Source="pack://application:,,,/ScrumTable.UI.View;component/Resources/ColorRay.png" />

                <s:SurfaceButton Visibility="{Binding InWizardMode, Converter={StaticResource ResourceKey=ConverterBoolToVisibility}}" FontSize="14" FontWeight="Bold" Grid.Row="3" Click="OnNextClick"  HorizontalAlignment="Left" VerticalAlignment="Center"  Width="200" Height="40" Margin="0,20,0,0" Style="{StaticResource SurfaceButtonStyle}">
                    <s:SurfaceButton.Content>
                        <Localization:Translate Uid="ProjectSettings_ButtonNext" Default="[Next]" />
                    </s:SurfaceButton.Content>
                </s:SurfaceButton>

            </Grid>
        </Grid>
    </CustomControl:ScrumTableScrollViewer>
</UserControls:ScrumUserControl>
